# -*- coding: utf-8 -*-
from numpy import genfromtxt
import numpy as np
from sklearn import datasets, linear_model

# dataPath = r"datasets/Delivery.csv" # 屏蔽转义字符
dataPath = r"datasets/DeliveryDummy.csv" # 屏蔽转义字符
deliveryData = genfromtxt(dataPath, delimiter=';') # 转化为numpy Array数据形式

print "data"
print deliveryData

'''
特征值列表 [行驶里程数,运输次数] [行驶里程数,运输次数,车型] 车型：分类型变量；
'''
X = deliveryData[:, :-1] 
Y = deliveryData[:, -1]  # 标签列表

print "X:"
print X
print "Y: "
print Y

regr = linear_model.LinearRegression() # 线性回归

regr.fit(X, Y) # 训练模型

print "coefficients"
print regr.coef_ # 权重参数值
print "intercept: "
print regr.intercept_ # 偏移量参数值

# xPred = [102, 6]
# yPred = regr.predict(xPred) # 预测
# print "predicted y: "
# print yPred